* Assessing the Policy Agenda in Private Bills
log close _all
log using LegislativeAgenda_logfile, name("Legislative Agenda") nomsg replace

*Descriptive - number of bills per Knesset
{
use KnessetBills_SubmittedFile.dta, clear

graph bar count if Knesset>=11, over(Knesset) ///
	scheme(s1color) ///
	subtitle("Count of PMB in Each Knesset") ///
	b1title("Knesset Number") ///
	ytitle("Sum of Private Bills") ylabel(, angle(0))  
graph save PMB.gph, replace 

graph bar count_w if Knesset>=11, over(Knesset) ///
	scheme(s1color) ///
	subtitle("Mean of Monthly PMB in Each Knesset ") ///
	b1title("Knesset Number") ///
	ytitle("Mean of Private Bills / Month") ylabel(, angle(0))  
graph save PMB_perMonth.gph, replace
graph combine PMB.gph PMB_perMonth.gph ///
	, scheme(s1color) /// title("PMB in Israeli Knesset, 1984-2019") 
	note("Knesset 11, 1984-1988; Knesset 12, 1988-1992; Knesset 13, 1992-1996; Knesset 14, 1996-1999;" ///
		"Knesset 15, 1999-2003; Knesset 16, 2003-2006; Knesset 17, 2006-2009; Knesset 18, 2009-2013;" ///
		"Knesset 19, 2013-2015; Knesset 20, 2015-2019")
}

*Assessing Legislative Agenda in Knessets 19-20
{
/* ACCESS POINTS
1. bills -> Legislative committee (party)
2. committee -> government support (government)
3. bills -> voted (party)
4. government support -> passed (Knesset)
*/
use LegislativeAgenda_data.dta, clear

* 1. Promoted = everything that promoted (based on party quota)
tab Status
recode Status (106/178 = 1) (104=0), gen(Tabled)
replace Tabled=1 if MCL_count==1
label variable Tabled "Knesset Agenda" 
label define tabled 0 "Not on Knesset Agenda" 1 "Knesset Agenda"
label values Tabled tabled
tab Tabled 

* 2. committee
/* 
an identifier for what gets to committee is the variable passed.  
this comes from the file of government decisions
*/
tab MCL_count
recode MCL_count (1=1) (.=0), gen(MCL_Considered)
label define mincomm 0 "Not Deliberated in Committee" 1 "Deliberated in Committee"
label values MCL_Considered mincomm
tab MCL_Considered // if bill reached committee
tab MCL_Considered Tabled // if bill reached committee


* 3. government support
tab MCL_passed // if billl passed committee 
label define passed 0 "No Government Support" 1 "Government Support"
label values MCL_passed passed
tab MCL_passed

* 4. passed = voted into law
tab Status
recode Status (118 = 1) (else=0), gen(Law)
label variable Law "Voted into Law" 
label define law 0 "No" 1 "Yes"
label values Law law
tab Law
tab Law MCL_Considered
tab Law MCL_passed


*assess flow 
gen flow=0
replace flow=1 if Tabled==1 
replace flow=2 if Tabled==1 & MCL_Considered==1
replace flow=3 if Tabled==1 & MCL_Considered==1 & MCL_passed==1 
replace flow=4 if Tabled==1 & MCL_Considered==1 & MCL_passed==1 & Law==1
tab flow
label define flow 0 "Submitted" 1 "Knesset Agenda" 2 "Cabinet Agenda" 3 "Cabinet Support" 4 "Law", replace
label values flow flow
tab flow

recode flow 0=1 1=2 2/4=3, gen(flow3)
label define flow3 1 "Submitted" 2 "Knesset Agenda" 3 "CCL Agenda"
label values flow3 flow3

recode flow 0=1 1=2 2=3 3/4=4, gen(flow4)
label define flow4 1 "Submitted" 2 "Knesset Agenda" 3 "CCL Agenda" 4 "CCL Support"
label values flow4 flow4

tab flow Knesset 
tab Tabled Knesset
prtest Tabled, by(Knesset)
prtest MCL_Considered, by(Knesset)
prtest MCL_passed, by(Knesset) // the only significant difference. 
prtest Law, by(Knesset)


*add partisan influence
gen CO_OPP=0
replace CO_OPP=3 if initiators_coalition_count!=0 & initiators_opposition_count==0
replace CO_OPP=2 if initiators_coalition_count!=0 & initiators_opposition_count!=0
replace CO_OPP=1 if initiators_coalition_count==0 & initiators_opposition_count!=0
label define co_opp 3 "Coalition" 2 "Coalition & Opposition" 1 "Opposition", replace
label values CO_OPP co_opp 
tab CO_OPP

tab CO_OPP
tab CO_OPP if flow>0
tab CO_OPP if flow>1
tab CO_OPP if flow>2	
	
}
	
* POLICY AGENDA AT DIFFERENT STAGES
{
tab flow
tab majorIL, sort // all bills
entropyetc majorIL

tab majorIL if flow>0, sort // bills on Knesset Agenda
entropyetc majorIL if flow>0

tab majorIL if flow>1, sort // bills on CCL agenda
entropyetc majorIL if flow>1

tab majorIL if flow>2, sort // bills passed by CCL
entropyetc majorIL if flow>2

tab majorIL if CO_OPP==1, sort // all bills opposition only
entropyetc majorIL if CO_OPP==1

tab majorIL if CO_OPP==2, sort // all bills coalition-opposition only
entropyetc majorIL if CO_OPP==2

tab majorIL if CO_OPP==3, sort // all bills coalition only
entropyetc majorIL if CO_OPP==3


*Proportion tests
gen PMB=1
save temp.dta, replace
*Proportion tests
{
**Major
use temp.dta, clear
collapse (sum) PMB, by(flow4 majorIL) 
bysort flow4: egen total=total(PMB)
gen PROP=100*PMB/total
keep PROP majorIL flow4
reshape wide PROP, i(majorIL) j(flow4)
save temp_proportions.dta, replace

gen abs12=abs(PROP1-PROP2)
egen sum_abs12=total(abs12)
gen CONVERGENCE12=100-(sum_abs12/2) // 1 and 2
gen abs13=abs(PROP1-PROP3)
egen sum_abs13=total(abs13)
gen CONVERGENCE13=100-(sum_abs13/2) // 1 and 3
gen abs14=abs(PROP1-PROP4)
egen sum_abs14=total(abs14)
gen CONVERGENCE14=100-(sum_abs14/2) // 1 and 4

gen abs23=abs(PROP2-PROP3)
egen sum_abs23=total(abs23)
gen CONVERGENCE23=100-(sum_abs23/2) // 2 and 3
gen abs24=abs(PROP2-PROP4)
egen sum_abs24=total(abs24)
gen CONVERGENCE24=100-(sum_abs24/2) // 2 and 4

gen abs34=abs(PROP3-PROP4)
egen sum_abs34=total(abs34)
gen CONVERGENCE34=100-(sum_abs34/2) // 3 and 4

**Minor
use temp.dta, clear
collapse (sum) PMB, by(flow4 minorIL) 
bysort flow4: egen total=total(PMB)
gen PROP=100*PMB/total
keep PROP minorIL flow4
reshape wide PROP, i(minorIL) j(flow4)
foreach var of varlist PROP1-PROP4{
	replace `var'=0 if missing(`var')
}
save temp_proportions_minor.dta, replace


gen abs12=abs(PROP1-PROP2)
egen sum_abs12=total(abs12)
gen CONVERGENCE12=100-(sum_abs12/2) // 1 and 2
gen abs13=abs(PROP1-PROP3)
egen sum_abs13=total(abs13)
gen CONVERGENCE13=100-(sum_abs13/2) // 1 and 3
gen abs14=abs(PROP1-PROP4)
egen sum_abs14=total(abs14)
gen CONVERGENCE14=100-(sum_abs14/2) // 1 and 4

gen abs23=abs(PROP2-PROP3)
egen sum_abs23=total(abs23)
gen CONVERGENCE23=100-(sum_abs23/2) // 2 and 3
gen abs24=abs(PROP2-PROP4)
egen sum_abs24=total(abs24)
gen CONVERGENCE24=100-(sum_abs24/2) // 2 and 4

gen abs34=abs(PROP3-PROP4)
egen sum_abs34=total(abs34)
gen CONVERGENCE34=100-(sum_abs34/2) // 3 and 4

}
*Convergence Coalition Opposition
{
**Major
use temp.dta, clear
collapse (sum) PMB, by(CO_OPP majorIL) 
bysort CO_OPP: egen total=total(PMB)
gen PROP=100*PMB/total
keep PROP majorIL CO_OPP 
reshape wide PROP, i(majorIL) j(CO_OPP)
rename PROP1 Opposition
rename PROP2 CoalitionOpposition
rename PROP3 Coalition
merge 1:1 majorIL using temp_proportions.dta 
rename PROP3 CCL

gen absOCCL=abs(Opposition-CCL)
egen sum_absOCCL=total(absOCCL)
gen CONVERGENCEOCCL=100-(sum_absOCCL/2) // Opposition and CCL
gen absCOCCL=abs(CoalitionOpposition-CCL)
egen sum_absCOCCL=total(absCOCCL)
gen CONVERGENCECOCCL=100-(sum_absCOCCL/2) // CoalitionOpposition-CCL
gen absCCCL=abs(Coalition-CCL)
egen sum_absCCCL=total(absCCCL)
gen CONVERGENCECCCL=100-(sum_absCCCL/2) // Coalition-CCL 


**Minor
use temp.dta, clear
collapse (sum) PMB, by(CO_OPP minorIL) 
bysort CO_OPP: egen total=total(PMB)
gen PROP=100*PMB/total
keep PROP minorIL CO_OPP 
reshape wide PROP, i(minorIL) j(CO_OPP)
foreach var of varlist PROP1-PROP3{
	replace `var'=0 if missing(`var')
}
rename PROP1 Opposition
rename PROP2 CoalitionOpposition
rename PROP3 Coalition
merge 1:1 minorIL using temp_proportions_minor.dta 
rename PROP3 CCL

gen absOCCL=abs(Opposition-CCL)
egen sum_absOCCL=total(absOCCL)
gen CONVERGENCEOCCL=100-(sum_absOCCL/2) // Opposition and CCL
gen absCOCCL=abs(CoalitionOpposition-CCL)
egen sum_absCOCCL=total(absCOCCL)
gen CONVERGENCECOCCL=100-(sum_absCOCCL/2) // CoalitionOpposition-CCL
gen absCCCL=abs(Coalition-CCL)
egen sum_absCCCL=total(absCCCL)
gen CONVERGENCECCCL=100-(sum_absCCCL/2) // Coalition-CCL 

}

*Importance
{
**Basic Laws
use temp.dta, clear
recode Basic (1=1) (.=0)
tab Basic
tab Basic flow4, column

tab Basic, sort // all bills
tab Basic if flow>0, sort // bills on Knesset Agenda
tab Basic if flow>1, sort // bills on CCL agenda
tab Basic if flow>2, sort // bills passed by CCL

keep if Basic==1
tab flow
}

log close _all
}




